home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 25.7 KB | 821 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: DrawFrm.cpp
- // Release Version: $ 1.0d11 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef DRAWFRM_H
- #include "DrawFrm.h"
- #endif
-
- #ifndef DRAWDEF_H
- #include "DrawDef.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWVIEW_H
- #include "DrawView.h"
- #endif
-
- #ifndef EDITCMDS_H
- #include "EditCmds.h"
- #endif
-
- #ifndef DRAWSEL_H
- #include "DrawSel.h"
- #endif
-
- #ifndef DRAWPRXY_H
- #include "DrawPrxy.h"
- #endif
-
- #ifndef SHPTRAKR_H
- #include "ShpTrakr.h"
- #endif
-
- #ifndef DRAWCMDS_H
- #include "DrawCmds.h"
- #endif
-
- #ifndef DRAWCLIP_H
- #include "DrawClip.h"
- #endif
-
- #ifndef UTILS_H
- #include "Utils.h"
- #endif
-
- #ifndef DRWDDCMD_H
- #include "DrwDDCmd.h"
- #endif
-
- #ifndef FWRULER_H
- #include "FWRuler.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWSCROLR_H
- #include "FWScrolr.h"
- #endif
-
- #ifndef FWSCLBAR_H
- #include "FWSclBar.h"
- #endif
-
- #ifndef FWGROWBX_H
- #include "FWGrowBx.h"
- #endif
-
- #ifndef FWPRHDLR_H
- #include "FWPrHdlr.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWMENU_H
- #include "FWMenu.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWCURSOR_H
- #include "FWCursor.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWBMPSHP_H
- #include "FWBmpShp.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfdrawframes
- #endif
-
- FW_DEFINE_CLASS_M1(CDrawFrame, FW_CEmbeddingFrame);
-
- //========================================================================================
- // CDrawFrame
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::CDrawFrame
- //----------------------------------------------------------------------------------------
-
- CDrawFrame::CDrawFrame(Environment* ev, ODFrame* odFrame, FW_CPresentation* presentation, CDrawPart* drawPart) :
- FW_CEmbeddingFrame(ev, odFrame, presentation, drawPart),
- fDrawPart(drawPart),
- fGrowBox(NULL),
- fSelection((CDrawSelection*)GetPresentation(ev)->GetSelection(ev)),
- fHorzRuler(NULL),
- fVertRuler(NULL),
- fGridShown(TRUE),
- fRulersShown(TRUE)
-
- {
- this->SetDroppable(ev, TRUE);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::~CDrawFrame
- //----------------------------------------------------------------------------------------
-
- CDrawFrame::~CDrawFrame()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CDrawFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- // ----- Edit Menu -----
- if (hasMenuFocus)
- {
- menuBar->EnableCommand(ev, kODCommandPaste, HasPropertyOnClipboard(ev, kODPropContents, NULL)); // we don't care about the type
-
- menuBar->EnableAndToggleCommand(ev, cGraphicsGrid, TRUE, fGridShown);
- menuBar->EnableAndToggleCommand(ev, cRulers, TRUE, fRulersShown);
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoMenu
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CDrawFrame::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Boolean handled = TRUE;
-
- switch (theMenuEvent.GetCommandID(ev))
- {
- case cGraphicsGrid:
- fGridShown = !fGridShown;
- GetContentView(ev)->Invalidate(ev);
- break;
-
- case cRulers:
- fRulersShown = !fRulersShown;
- ToggleRulers(ev, fRulersShown);
- Invalidate(ev);
- break;
-
- default:
- handled = FALSE;
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewEditCommand
- //----------------------------------------------------------------------------------------
- FW_CEditCommand* CDrawFrame::NewEditCommand(Environment* ev, ODCommandID commandID) // Override
- {
- #if defined(FW_BUILD_WIN) && FW_OPENDOC_VERSION == FW_OPENDOC_DR1
- FW_Boolean undoAble = FALSE;
- #else
- FW_Boolean undoAble = TRUE;
- #endif
-
- return FW_NEW(CDrawEditCommand, (ev, commandID, fDrawPart, this, fSelection, undoAble));
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoActivateEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CDrawFrame::DoActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent)
- {
- // if (IsActive(ev))
- // fSelection->DrawAllHandles(ev, this, theActivateEvent.IsActivating(ev));
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::AdjustZoomedWindowSize
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::AdjustZoomedWindowSize(Environment* ev, FW_CPoint& proposedSize)
- {
- proposedSize = fDrawPart->GetDrawingSize();
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::AdjustWindowGrowLimits
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::AdjustWindowGrowLimits(Environment* ev, FW_CPoint& minSize, FW_CPoint& maxSize)
- {
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
-
- minSize.x = FW_IntToFixed(72) + sbSize.x;
- minSize.y = FW_IntToFixed(72) + sbSize.y;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::GeometryChanged
- //----------------------------------------------------------------------------------------
- // the geometry (clip shape, external or Internal transform) of one of my facet or one of my
- // embedding facet as changed
-
- void CDrawFrame::GeometryChanged(Environment *ev,
- ODFacet* odFacet,
- FW_Boolean clipShapeChanged,
- FW_Boolean externalTransformChanged)
- {
- FW_CEmbeddingFrame::GeometryChanged(ev, odFacet, clipShapeChanged, externalTransformChanged);
-
- if (externalTransformChanged)
- {
- CDrawFacetClipper facetClipper(ev, fDrawPart);
- facetClipper.ClipEmbeddedFacets(ev, this, odFacet, NULL);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::FrameShapeChanged
- //----------------------------------------------------------------------------------------
- // My Frame shape has changed I need to clip my embedded facets
-
- void CDrawFrame::FrameShapeChanged(Environment *ev)
- {
- FW_CEmbeddingFrame::FrameShapeChanged(ev);
-
- CDrawFacetClipper facetClipper(ev, fDrawPart);
- facetClipper.Clip(ev, this, NULL);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::CreateEmbeddedFacet
- //----------------------------------------------------------------------------------------
-
- FW_DECLARE_THROW_POINT (CDrawFrame_CreateEmbeddedFacet);
-
- ODFacet* CDrawFrame::CreateEmbeddedFacet(Environment* ev,
- ODFacet* embeddingFacet,
- FW_MProxy* proxy,
- ODFrame* embeddedFrame,
- ODShape* proposedClipShape)
- {
- FW_CRect embeddedFrameBounds = ((CProxyShape*)proxy)->GetFrameRect(ev);
-
- FW_CAcquiredODTransform aqExternalTransform = ::FW_NewODTransform(ev, embeddedFrameBounds.TopLeft());
-
- FW_CHECK_THROW_POINT (CDrawFrame_CreateEmbeddedFacet);
- return embeddingFacet->CreateEmbeddedFacet(ev,
- embeddedFrame,
- proposedClipShape,
- aqExternalTransform,
- NULL, // Canvas
- NULL, // biasCanvas
- NULL, // siblingFacet
- kODFrameInFront);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::CreateSubViews
- //----------------------------------------------------------------------------------------
-
- const FW_CFixed kRulerWidth = FW_IntToFixed(15);
-
- void CDrawFrame::CreateSubViews(Environment* ev)
- {
- FW_CRect frameRect = GetBounds(ev);
- FW_CRect contentRect(frameRect);
-
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
-
- if (fRulersShown) {
- // Make space for rulers
- contentRect.top += kRulerWidth;
- contentRect.left += kRulerWidth;
- }
-
- if (this->IsRoot(ev))
- {
- // Make space for scrollbars
- contentRect.bottom -= sbSize.y;
- contentRect.right -= sbSize.x;
- }
-
- FW_CPoint drawingSize = fDrawPart->GetDrawingSize();
-
- // ----- Create the content view
- CDrawView* contentView = new CDrawView(ev, this, contentRect, fDrawPart);
- contentView->MakeContentView(ev);
- contentView->SetExtent(ev, drawingSize); // Set the content's extent
-
- // ----- Create scroll bars and grow box in root frame only -----
- if (this->IsRoot(ev))
- {
- // ----- Create the vertical scroll bar
- FW_CRect vertSbRect(contentRect.right,
- frameRect.top - FW_kFixedPos1,
- contentRect.right + sbSize.x + FW_kFixedPos1,
- contentRect.bottom + FW_kFixedPos1);
- FW_CScrollBar* vertSB = new FW_CScrollBar(ev, this, 0, vertSbRect);
- // AdjustMinorScrollUnits(ev, vertSB, contentRect.Height());
-
- // ----- Create the horizontan scroll bar
- FW_CRect horzSbRect(frameRect.left - FW_kFixedPos1,
- contentRect.bottom,
- contentRect.right + FW_kFixedPos1,
- contentRect.bottom + sbSize.y + FW_kFixedPos1);
- FW_CScrollBar* horzSB = new FW_CScrollBar(ev, this, 0, horzSbRect);
- // AdjustMinorScrollUnits(ev, horzSB, contentRect.Width());
-
- // ----- Create the GrowBox gadget
- fGrowBox = new FW_CGrowBox(ev, this, 0, contentRect.BotRight());
-
- // ----- add a scroller to content view -----
- contentView->AddScrollBarScroller(ev, horzSB, vertSB);
- }
-
- // ----- Create the rulers
- FW_CRect HorzRulerRect(contentRect.left, contentRect.top - kRulerWidth,
- contentRect.right, contentRect.top);
- fHorzRuler = new FW_CRuler(ev, this, HorzRulerRect, FW_CView::kXaxis);
- FW_CPoint horzRulerExtent(drawingSize.x, kRulerWidth);
- fHorzRuler->SetExtent(ev, horzRulerExtent); // Set the content's extent
-
- FW_CRect VertRulerRect(contentRect.left - kRulerWidth, contentRect.top,
- contentRect.left, contentRect.bottom);
- fVertRuler = new FW_CRuler(ev, this, VertRulerRect, FW_CView::kYaxis);
- FW_CPoint vertRulerExtent(kRulerWidth, drawingSize.y);
- fVertRuler->SetExtent(ev, vertRulerExtent); // Set the content's extent
-
- if (!fRulersShown) {
- fHorzRuler->SetVisible(ev, FALSE);
- fVertRuler->SetVisible(ev, FALSE);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::AdjustSubViews
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::AdjustSubViews(Environment* ev)
- {
- FW_CRect frameRect = GetBounds(ev);
- FW_CRect contentRect(frameRect);
-
- FW_CView* contentView = GetContentView(ev);
- FW_ASSERT(contentView != NULL);
-
- if (fRulersShown) {
- // Make space for rulers
- contentRect.top += kRulerWidth;
- contentRect.left += kRulerWidth;
- }
-
- if (IsRoot(ev))
- {
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
-
- // Get scroller from content view
- FW_CScrollBarScroller* scroller = (FW_CScrollBarScroller*)contentView->GetScroller(ev);
- FW_CScrollBar* scrollBar;
-
- contentRect.bottom -= sbSize.y;
- contentRect.right -= sbSize.x;
-
- // adjust bounds of gadgets & invalidate old/new positions to force redrawing
- if (scrollBar = scroller->GetScrollBar(ev, FW_CScrollBarScroller::kVertical))
- {
- scrollBar->Invalidate(ev);
- scrollBar->SetLocation(ev, FW_CPoint(contentRect.right, frameRect.top - FW_kFixedPos1));
- scrollBar->SetSize(ev, FW_CPoint(sbSize.x + FW_kFixedPos1, contentRect.bottom - frameRect.top + FW_kFixedPos1 + FW_kFixedPos1));
- scrollBar->Invalidate(ev);
- // AdjustMinorScrollUnits(ev, scrollBar, contentRect.Height());
- }
-
- if (scrollBar = scroller->GetScrollBar(ev, FW_CScrollBarScroller::kHorizontal))
- {
- scrollBar->Invalidate(ev);
- scrollBar->SetLocation(ev, FW_CPoint(frameRect.left - FW_kFixedPos1, contentRect.bottom));
- scrollBar->SetSize(ev, FW_CPoint(contentRect.right - frameRect.left + FW_kFixedPos1 + FW_kFixedPos1, sbSize.y + FW_kFixedPos1));
- scrollBar->Invalidate(ev);
- // AdjustMinorScrollUnits(ev, scrollBar, contentRect.Width());
- }
-
- if (fGrowBox)
- {
- fGrowBox->Invalidate(ev);
- fGrowBox->SetLocation(ev, contentRect.BotRight());
- fGrowBox->Invalidate(ev);
- }
-
- scroller->UpdateScrollParameters(ev);
- }
-
- if (fRulersShown) {
- // adjust rulers
- if (fHorzRuler) {
- fHorzRuler->SetSize(ev, FW_CPoint(contentRect.right - contentRect.left, kRulerWidth));
- }
- if (fVertRuler) {
- fVertRuler->SetSize(ev, FW_CPoint(kRulerWidth, contentRect.bottom - contentRect.top));
- }
- }
-
- contentView->SetSize(ev, contentRect.Size());
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewDragCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDragCommand* CDrawFrame::NewDragCommand(Environment *ev, FW_CFrame* theFrame)
- {
- CDragCommand* dragCommand = FW_NEW(CDragCommand,
- (ev, fDrawPart, theFrame,
- fSelection,
- FW_kCanUndo));
- return (FW_CDragCommand*) dragCommand;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewDropCommand
- //----------------------------------------------------------------------------------------
- FW_CDropCommand* CDrawFrame::NewDropCommand(Environment *ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* facet,
- const FW_CPoint& dropPoint)
- {
- CDropCommand* dropCommand = FW_NEW(CDropCommand,
- (ev, fDrawPart, frame,
- dropInfo, facet, dropPoint,
- FW_kCanUndo));
- return (FW_CDropCommand*) dropCommand;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::ToggleRulers
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::ToggleRulers(Environment *ev, FW_Boolean visible)
- {
- FW_ASSERT(fHorzRuler != NULL && fVertRuler != NULL);
- fHorzRuler->SetVisible(ev, visible);
- fVertRuler->SetVisible(ev, visible);
-
- // updates the contentView bounds
- FW_CRect contentRect = GetBounds(ev);
- FW_CView* contentView = GetContentView(ev);
- if (IsRoot(ev)) {
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
- contentRect.bottom -= sbSize.y;
- contentRect.right -= sbSize.x;
- }
-
- if (visible) {
- contentRect.top += kRulerWidth;
- contentRect.left += kRulerWidth;
- contentView->SetLocation(ev, contentRect.TopLeft());
- }
- else {
- contentView->SetLocation(ev, contentRect.TopLeft());
- }
- contentView->SetSize(ev, contentRect.Size());
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::EmbedSingleFrame
- //----------------------------------------------------------------------------------------
-
- FW_DECLARE_THROW_POINT (DrawFrameEmbedSingleFrame1);
- FW_DECLARE_THROW_POINT (DrawFrameEmbedSingleFrame2);
- FW_DECLARE_THROW_POINT (DrawFrameEmbedSingleFrame3);
-
- void CDrawFrame::EmbedSingleFrame(Environment* ev,
- ODPart* embeddedPart,
- ODFrame* embeddedFrame,
- ODShape* frameShape)
- {
- /*
- *** Let's think about failure handling here.
-
- Just throwing exceptions isn't enough. Looking through this method we can see *lots* of
- methods which perform state changes. If any exception was thrown before all state
- changes were complete we'd wind up with a document in a very sorry state. And since
- embedding is an expensive (memory-requiring) process we have a good chance of failures
- occuring.
-
- When an error occurs, proper cleanup would make it look as though we had never entered
- the method in the first place. That means if several state changes are required,
- cleaning up after an exception requires us to *undo* all state changes up to the point
- where we failed. So we need to look at each line and determine if it makes a state
- change which needs to be "protected" from subsequent possible failures. Anything after
- a state change which is deemed "dangerous" is wrapped in a try/catch block, like so:
- <state change 1>
- try {
- <state change 2>
- } catch (...) {
- <undo state change 1>
- }
-
- Step 1: "fSelection->CloseSelection". This deselects everything. It is a state change
- but it's not important - i.e. it's not important for us to restore the selection if an
- exception occurs later. So we don't have to protect it.
-
- Steps 2 to 4: these are safe; everything is on the stack and doesn't change state,
- or, in the case of "FW_CAcquiredODShape aqFrameShape = ...", the destructor will
- clean up for us in the event of an exception being thrown.
-
- Step 5: "new CProxyShape" requires cleanup. We're allocating something on the heap here;
- suppose the very next line threw an exception? In that case we would fail to properly
- dispose of it, and would have a memory leak. Therefore we put everything *after* the
- allocation inside a try/catch block.
-
- Step 6: "AddShape" also requires cleanup. We're presuming that we will complete the embed
- process. If we don't then having this pointer in the shape list would be bad.
-
- Step 7: This is the important bit, but if it fails we don't worry. Whoever called us will
- deal with it. What's important is that none of the other *preperatory* state changes we had
- to make to support this step will be forgotten.
-
- Step 8: This is another thing which can throw but this one isn't important. If we can't
- select the newly-added shape then so what? - we were able to embed the part, which is what
- matters. Wrap in try/catch to suppress a misleading "out of memory" alert box.
- */
- // ----- Step 1: Close the current selection -----
- fSelection->CloseSelection(ev);
-
- // ----- Step 2: Calculate the default shape rect
- FW_CRect shapeRect;
- if (frameShape)
- {
- shapeRect = FW_GetShapeBoundingBox(ev, frameShape);
- shapeRect.Offset(-shapeRect.left, -shapeRect.top);
- }
- else
- {
- shapeRect.SetInt(0, 0, 80, 80);
- }
-
- // ----- Step 3: Calculate the shape of the embedded frame -----
- FW_CAcquiredODShape aqFrameShape = ::FW_NewODShape(ev, shapeRect);
-
- // ----- Step 4: Calculate its position -----
- // ----- We placing it in the middle of the content view -----
- FW_CRect frameBounds = GetContentView(ev)->GetBounds(ev);
- frameBounds.Place(FW_kFixed0, FW_kFixed0);
- GetContentView(ev)->ViewToViewContent(ev, frameBounds);
- shapeRect.PlaceInCenter(frameBounds);
-
- // ----- Step 5: Create the proxy shape -----
- CProxyShape* proxyShape = new CProxyShape(ev, shapeRect, fDrawPart);
- // make sure that if an exception occurs before we complete this method that
- // we dispose of the shape
- FW_TRY {
-
- // Step 6: ----- Add the shape to the list of shape -----
- FW_CHECK_THROW_POINT (DrawFrameEmbedSingleFrame1);
- fDrawPart->AddShape(ev, proxyShape);
- // this is another state change which needs cleanup. This is kind of screwy
- // actually - why are we adding the shape before we've embedded it? Probably
- // the following code will require this. Therefore we need to ensure that if
- // for some reason we fail to embed that we remove the now-unused shape.
- FW_TRY {
-
- // Step 7: ----- Embed the Part/Frame -----
- FW_CHECK_THROW_POINT (DrawFrameEmbedSingleFrame2);
- GetPresentation(ev)->Embed(ev,
- embeddedPart,
- embeddedFrame,
- proxyShape,
- aqFrameShape,
- FW_CPart::gViewAsFrameToken,
- NULL, // no presentation
- 0, // groupe id
- FALSE); // sub frame
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING () {
- // cleanup for Step 6 - since embedding failed we don't want this shape pointer dangling
- fDrawPart->RemoveShape (ev, proxyShape);
- FW_THROW_SAME ();
- }
- FW_CATCH_END
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING () {
- // cleanup for Step 5
- delete proxyShape;
- FW_THROW_SAME ();
- }
- FW_CATCH_END
-
- // Step 8: ----- Add it to the selection -----
- // Theoretically AddToSelection could throw (since it allocates memory)
- // but since all it does is select the newly added shape we don't care
- // if it fails. It's not worth aborting the entire embed process just because
- // we couldn't make it select. It would also be strange to see an "out of memory"
- // error box come up after embedding when it *did* embed ok.
- FW_TRY {
- FW_CHECK_THROW_POINT (DrawFrameEmbedSingleFrame3);
- fSelection->AddToSelection(ev, proxyShape, FALSE);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING () {
- // do nothing, do NOT rethrow
- }
- FW_CATCH_END
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- // The only thing to draw is the top left corner box
- if (fRulersShown)
- {
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
- FW_CRect box(FW_kFixedNeg1, FW_kFixedNeg1, kRulerWidth, kRulerWidth);
- FW_CRectShape::RenderRect(vc, box, FW_kFill, FW_kWhiteEraseInk);
- FW_CRectShape::RenderRect(vc, box, FW_kFrame);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewPrintHandler
- //----------------------------------------------------------------------------------------
-
- FW_CPrintHandler* CDrawFrame::NewPrintHandler(Environment* ev)
- {
- FW_CPart* part = GetPart(ev);
- return new FW_CPrintHandler(part, this);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::IsCurrentlyPrintable
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CDrawFrame::IsCurrentlyPrintable(Environment* ev) const
- {
- FW_CPrivOrderedCollection* shapeList = fDrawPart->GetShapeList();
- return shapeList->Count() != 0;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::GetPrintContentExtent
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::GetPrintContentExtent(Environment *ev, FW_CPoint& extent) const
- {
- // We only enable print command if there is anything to print
- FW_ASSERT(fDrawPart->GetShapeList()->Count() != 0);
-
- // Go through all the shapes and determine their bounds
- extent.Set(FW_kFixed0, FW_kFixed0);
- FW_COrderedCollectionIterator ite(fDrawPart->GetShapeList());
- for (CBaseShape* theShape = (CBaseShape*)ite.First(); ite.IsNotComplete(); theShape = (CBaseShape*)ite.Next())
- {
- FW_CRect updateBox;
- theShape->GetUpdateBox(updateBox);
-
- if (updateBox.right > extent.x)
- extent.x = updateBox.right;
-
- if (updateBox.bottom > extent.y)
- extent.y = updateBox.bottom;
- }
-
- FW_ASSERT(extent.x && extent.y);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::RevealFrame
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CDrawFrame::RevealFrame(Environment *ev,
- ODFrame* embeddedFrame,
- ODShape* revealShape)
- {
- FW_UNUSED(revealShape);
-
- // Look thru shape list for a proxy shape that matches the embeddedFrame
- FW_COrderedCollectionIterator iter(fDrawPart->GetShapeList());
- for (CBaseShape* shape = (CBaseShape*)iter.First(); iter.IsNotComplete(); shape = (CBaseShape*)iter.Next())
- {
- if (shape->GetShapeType() == kProxyShape)
- {
- CProxyShape* proxyShape = (CProxyShape*)shape;
- ODFrame* proxyEmbeddedFrame = proxyShape->GetEmbeddedFrame(ev, this);
- if (proxyEmbeddedFrame == embeddedFrame)
- {
- // Select the proxy shape and redraw it
- fSelection->CloseSelection(ev);
- fSelection->AddToSelection(ev, proxyShape, TRUE);
- return TRUE;
- }
- }
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::FacetAdded
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::FacetAdded(Environment* ev, ODFacet* facet)
- {
- FW_CEmbeddingFrame::FacetAdded(ev, facet); // Call inherited
-
- // Perform "DoPostCreate"-type initialization here.
- fDrawPart->DoPostCreate(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::ExternalizeFrame
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::ExternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- FW_CEmbeddingFrame::ExternalizeFrame(ev, storageUnitView);
-
- FW_CStorageUnitSink sink(storageUnitView);
- FW_CWritableStream stream(&sink);
-
- stream << fGridShown;
- stream << fRulersShown;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::InternalizeFrame
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::InternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- FW_CEmbeddingFrame::InternalizeFrame(ev, storageUnitView);
-
- FW_CStorageUnitSink sink(storageUnitView);
- FW_CReadableStream stream(&sink);
-
- stream >> fGridShown;
- stream >> fRulersShown;
- }
-
-